package com.becca.cake.model.order;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.StringUtils;

import com.becca.cake.core.exception.ServiceException;

/**
 * 今天支付订单信息
 * @copyright  尊星(上海)信息科技有限公司
 * @author hejinguo
 * @date 2016年11月21日 下午5:02:05
 */
public class OrdersTodayModel implements Serializable {
    /**  */
    private static final long  serialVersionUID         = 5297227598932466904L;

    /**订单状态(0:待支付）*/
    public static final Byte   ORDER_STATUS_WAIT_PAY    = 0;

    /**手机号不能为空*/
    public static final String MOBILE_IS_NULL           = "手机号不能为空";

    /**支付金额不能为空*/
    public static final String TOTAL_AMOUNT_IS_NULL     = "支付金额不能为空";

    /**支付金额必须大于0*/
    public static final String TOTAL_AMOUNT_IS_LESS_ONE = "支付金额必须大于0";

    /**支付方式不能为空*/
    public static final String PAY_TYPE_IS_NULL         = "支付方式不能为空";

    /**订单非待支付订单,请重新支付*/
    public static final String ORDER_STATUS_NO_PAY      = "订单非待支付订单,请重新支付";

    /**支付状态(0:待支付)*/
    public static final Byte   PAY_STATUS_WAIT_PAY      = 0;

    /**支付状态(1:已支付)*/
    public static final Byte   PAY_STATUS_ALREADY_PAY   = 1;

    private Integer            id;

    private String             orderCode;

    private String             userPhone;
    /**支付状态(0:待支付 1:已支付 2:超时未支付)*/
    private Byte               payStatus;
    /**支付方式(0:微信 1：支付宝)*/
    private Byte               payType;

    private Date               payDate;

    private Double             totalAmount;

    private String             payNo;

    private String             outTradeNo;

    private String             remark;
    /**创建时间*/
    private Date               createdDate;
    /**创建人*/
    private String             createdName;
    /**修改时间*/
    private Date               updatedDate;
    /**修改人*/
    private String             updatedName;

    /**
     * 今日订单支付数据校验
     * @param userPhone
     * @param totalAmount
     * @param payType
     */
    public static void validatesSaveOrderParam(String userPhone, Double totalAmount, Byte payType) {
        if (StringUtils.isEmpty(userPhone)) {
            throw new ServiceException(OrdersTodayModel.MOBILE_IS_NULL);
        }
        if (totalAmount == null) {
            throw new ServiceException(OrdersTodayModel.TOTAL_AMOUNT_IS_NULL);
        }
        if (totalAmount <= 0) {
            throw new ServiceException(OrdersTodayModel.TOTAL_AMOUNT_IS_LESS_ONE);
        }
        if (payType == null) {
            throw new ServiceException(OrdersTodayModel.PAY_TYPE_IS_NULL);
        }
    }

    /**
     * 未支付订单数据校验
     * @param orderModel
     */
    public static void validateNoPayParam(OrdersTodayModel orderModel) {
        if (orderModel == null) {
            throw new ServiceException(OrderModel.ORDER_NO_EXISTS);
        }
        if (!OrdersTodayModel.PAY_STATUS_WAIT_PAY.equals(orderModel.getPayStatus())) {//待支付
            throw new ServiceException(OrdersTodayModel.ORDER_STATUS_NO_PAY);
        }
    }

    public Integer getId() {
        return id;
    }

    public String getOrderCode() {
        return orderCode;
    }

    public String getUserPhone() {
        return userPhone;
    }

    public Byte getPayStatus() {
        return payStatus;
    }

    public Byte getPayType() {
        return payType;
    }

    public Date getPayDate() {
        return payDate;
    }

    public Double getTotalAmount() {
        return totalAmount;
    }

    public String getPayNo() {
        return payNo;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public String getRemark() {
        return remark;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public String getCreatedName() {
        return createdName;
    }

    public Date getUpdatedDate() {
        return updatedDate;
    }

    public String getUpdatedName() {
        return updatedName;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    public void setPayStatus(Byte payStatus) {
        this.payStatus = payStatus;
    }

    public void setPayType(Byte payType) {
        this.payType = payType;
    }

    public void setPayDate(Date payDate) {
        this.payDate = payDate;
    }

    public void setTotalAmount(Double totalAmount) {
        this.totalAmount = totalAmount;
    }

    public void setPayNo(String payNo) {
        this.payNo = payNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }

    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }

    public void setUpdatedName(String updatedName) {
        this.updatedName = updatedName;
    }

}
